package cn.factorybox.item.controller;

import cn.factorybox.common.entity.Result;
import cn.factorybox.item.annotation.ControllerLogAnnotation;
import cn.factorybox.item.service.FeedBackService;
import cn.factorybox.model.entity.FeedBack;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author flypig
 * @version 1.0
 * @date 2020-11-23 13:50
 */

@Api(tags = "反馈信息管理")
@RestController
public class FeedBackController {

    @Autowired
    private FeedBackService feedBackService;

    @ControllerLogAnnotation(moduleName = "反馈信息管理", functionName = "提交反馈信息")
    @ApiOperation(value = "提交反馈信息", notes = "提交反馈信息")
    @PostMapping("/feedback")
    public Result saveFeedBack(@RequestBody FeedBack feedBack) {
        feedBackService.insertFeedBack(feedBack);
        return Result.ok("反馈信息提交成功");
    }

    @ControllerLogAnnotation(moduleName = "反馈信息管理", functionName = "获取反馈信息")
    @ApiOperation(value = "获取反馈信息", notes = "获取反馈信息")
    @GetMapping("/feedback")
    public Result selectFeedBackList(@RequestParam("master") String masterId) {
        List<FeedBack> feedBackList = feedBackService.selectList(masterId);
        return new Result(feedBackList,"获取反馈信息成功");
    }

    @ControllerLogAnnotation(moduleName = "反馈信息管理", functionName = "删除反馈信息")
    @ApiOperation(value = "删除反馈信息", notes = "删除反馈信息")
    @DeleteMapping("/feedback")
    public Result deleteFeedBack(@RequestParam("id") String id) {
        feedBackService.delete(id);
        return Result.ok("删除反馈信息成功");
    }

}
